import request from '@/utils/request'

export default {
    // 分页查询
    // page:当前页, limit:每页的记录数
    selectByPage(page, limit) {
        return request({
          url: `/rbac/role/selectByPage?page=${page}&limit=${limit}`,
          method: 'get'
        })
    },
    deleteById(id) {
        return request({
          url: `/rbac/role/deleteById/${id}`,
          method: 'delete'
        })
    },
    add(role) {
      return request({
        url: `/rbac/role/add`,
        method: 'post',
        data: role
      })
    },
    selectById(id) {
      return request({
        url: `/rbac/role/selectById/${id}`,
        method: 'get'
      })
    },
    update(role) {
      return request({
        url: `/rbac/role/update`,
        method: 'put',
        data: role
      })
    },
    selectAssignedRole(userId) {
      return request({
        url: `/rbac/role/selectAssignedRole/${userId}`,
        method: 'get'
      })
    },
    assignRole(userId, roleIds) {
      return request({
        url: `/rbac/role/assignRole`,
        method: 'post',
        params: {userId, roleIds}
      })
    }
}
